package com.happy.zebra.admin.controller;

import com.happy.zebra.admin.api.vo.AssistPermissionVO;
import com.happy.zebra.admin.service.PermissionService;
import com.shycloud.mido.common.core.util.R;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 权限模块 controller
 *
 * @author nianhua.jiang
 * @description
 * @date 2021/02/02
 */
@RestController
@AllArgsConstructor
@RequestMapping("/permission")
@ApiOperation("权限模块 controller")
public class PermissionController {

	/** 权限业务 service */
	private PermissionService permissionService;

	/**
	 * 查询此教师是否有教辅权限
	 *
	 * @param teacherId 教师ID
	 * @return com.shycloud.mido.common.core.util.R
	 * @author nianhua.jiang
	 * @date 2021/2/2 15:27
	 **/
	@GetMapping("checkAssistPermission")
	public R<AssistPermissionVO> checkAssistPermission(String teacherId) {
		return new R<>(permissionService.checkAssistPermission(teacherId));
	}

	/**
	 * 试用
	 *
	 * @param teacherId
	 * @return com.shycloud.mido.common.core.util.R
	 * @author nianhua.jiang
	 * @date 2021/2/2 16:20
	 **/
	@GetMapping("activeAssistPermission")
	public R activeAssistPermission(String teacherId, String type) {

		// 试用权限
		if ("1".equals(type)) {
			return new R(permissionService.activeAssistPermissionTry(teacherId));
		}

		// TODO 购买权限
		if ("2".equals(type)) {
			return new R();
		}
		return new R();
	}

	// 2021/03/30 新增 基础练琴作业权限：完成作业/教师检查作业/   TODO:可以考虑以切面的方式进行权限认证


}
